package com.mantou.mantouaiagent.tools.all;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mantou.mantouaiagent.tools.constant.FileOperationTool;
import com.mantou.mantouaiagent.tools.*;
import jakarta.annotation.Resource;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.ai.tool.ToolCallbacks;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ToolRegistration {

    @Value("${search-api.api-key}")
    private String apiKey;

    @Value("${zhipu-api.api-key}")
    private String zhipuApiKey;
    @Resource
    private ObjectMapper objectMapper;

    @Bean
    public ToolCallback[] allTools() {
        FileOperationTool fileOperationTool = new FileOperationTool();
        DateTimeTools dateTimeTools = new DateTimeTools();
        WebSearchTools webSearchTools = new WebSearchTools(apiKey);
        ZhipuWebSearchTool zhipuWebSearchTool = new ZhipuWebSearchTool(objectMapper, zhipuApiKey);
        TerminateTool terminateTool = new TerminateTool();
        OpenMeteoTool openMeteoTool = new OpenMeteoTool();
        ResourceDownloadTool resourceDownloadTool = new ResourceDownloadTool();
        PDFGenerationTool pdfGenerationTool = new PDFGenerationTool();
        return ToolCallbacks.from(
            fileOperationTool,
                terminateTool,
                openMeteoTool,
                webSearchTools,
                zhipuWebSearchTool,
                resourceDownloadTool,
                pdfGenerationTool,
                dateTimeTools
        );
    }
}
